package com.atguigu.dao.impl;

import com.atguigu.bean.Cart;
import com.atguigu.bean.Order;
import com.atguigu.bean.User;
import com.atguigu.dao.BaseDao;
import com.atguigu.dao.OrderDao;

import java.util.List;

public class OrderDaoImpl extends BaseDao<Order> implements OrderDao{
    @Override
    public void addOrder(Order order) {
        String sql="insert into  t_order values(null,?,?,?,?,?,?)";
        update(sql,
                order.getOrder_sequence(),
                order.getCreate_time(),
                order.getTotal_count(),
                order.getTotal_amount(),
                order.getOrder_status(),
                order.getUser_id()
        );
    }

    @Override
    public int findOrderId(String sequence) {
        String sql="select order_id from t_order where order_sequence=?";
        return (int)getObject(Order.class,sql,sequence);
    }


    @Override
    public List<Order> findAllOrderById(int id) {
        String sql="select * from  t_order where user_id=? ";
        return getBeanList(Order.class,sql,id);
    }
}
